package com.ymatou.query.seller.trading.api.testcase;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.seller.trading.api.parameter.GetAppSellerOrderBean;
import com.ymatou.query.seller.trading.api.parameter.Sp_GetAppSellerOrdersByOrderIds;
import com.ymatou.query.seller.trading.api.parameter.AppResponse.GetAppSellerOrderResponse;
import com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderInfoDetail;
import com.ymatou.query.seller.trading.api.service.GetAppSellerOrderCall;
import com.ymatou.query.seller.trading.api.service.OrderCreate;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.common.entitie.C2COrderInfo;
import com.ymttest.common.entitie.C2COrderInfo.C2COrderInfoExt;
import com.ymttest.common.entitie.SellerOrderInfoV3;
import com.ymttest.database.model.ProductPromotion;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;

/**
 * 获取卖家订单详情
 * 
 * @date 2016-09-14
 */
@TestSuite
public class Ts_GetAppSellerOrder {
	private static GetAppSellerOrderBean getAppSellerOrderBean;
	private static GetAppSellerOrderCall getAppSellerOrderCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取卖家订单详情");
	}

	@Before
	public void caseUp() {
		getAppSellerOrderBean = new GetAppSellerOrderBean();
		getAppSellerOrderCall = new GetAppSellerOrderCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getAppSellerOrderCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verify() {
		GetAppSellerOrderResponse expect = new GetAppSellerOrderResponse();
		ConstructExpectedResponse(expect);
		GetAppSellerOrderResponse actual = getAppSellerOrderCall
				.getAppSellerOrderResponse();
		if (expect.getOrder() == null) {
			DataUtil.verifyEquals(null, actual.getOrder(), "验证期望的Order为null");
		} else {
			verifyOrder(expect.getOrder(), actual.getOrder());
		}
	}

	private void verifyOrder(SellerOrderInfoDetail expect,
			SellerOrderInfoDetail actual) {
		DataUtil.verifyEquals(expect.getOrderCancelReason(),
				actual.getOrderCancelReason(), "验证OrderCancelReason");
		DataUtil.verifyEquals(expect.getAddress(), actual.getAddress(),
				"验证Address");
		DataUtil.verifyEquals(expect.getMobile(), actual.getMobile(), "Mobile");
		DataUtil.verifyEquals(expect.getRecipientName(),
				actual.getRecipientName(), "RecipientName");
		DataUtil.verifyEquals(expect.getZipCode(), actual.getZipCode(),
				"ZipCode");

		DataUtil.verifyEquals(expect.getSalesType(), actual.getSalesType(),
				"验证OrderId=[" + expect.getOrderId() + "]的SalesType");
		DataUtil.verifyEquals(expect.getOrderGroupId(),
				actual.getOrderGroupId(), "验证OrderId=[" + expect.getOrderId()
						+ "]的OrderGroupId");
		DataUtil.verifyEquals(expect.getOrderStatus(), actual.getOrderStatus(),
				"验证OrderId=[" + expect.getOrderId() + "]的OrderStatus");
		DataUtil.verifyEquals(expect.getRiskVerifiedStatus(),
				actual.getRiskVerifiedStatus(),
				"验证OrderId=[" + expect.getOrderId() + "]的RiskVerifiedStatus");
		DataUtil.verifyEquals(expect.getBuyerUserId(), actual.getBuyerUserId(),
				"验证OrderId=[" + expect.getOrderId() + "]的BuyerUserId");
		DataUtil.verifyEquals(expect.getBuyerUserLoginId(),
				actual.getBuyerUserLoginId(),
				"验证OrderId=[" + expect.getOrderId() + "]的BuyerUserLoginId");
		DataUtil.verifyEquals(expect.getLeaveWord(), actual.getLeaveWord(),
				"验证OrderId=[" + expect.getOrderId() + "]的LeaveWord");
		DataUtil.verifyEquals(expect.isPaidInFull(), actual.isPaidInFull(),
				"验证OrderId=[" + expect.getOrderId() + "]的PaidInFull");
		DataUtil.verifyEquals(expect.getSellerNote(), actual.getSellerNote(),
				"验证OrderId=[" + expect.getOrderId() + "]的SellerNote");
		DataUtil.verifyEquals(expect.getBuyerInBlacklist(),
				actual.getBuyerInBlacklist(),
				"验证OrderId=[" + expect.getOrderId() + "]的BuyerInBlacklist");
		DataUtil.verifyEquals(expect.getNeedUploadIdCard(),
				actual.getNeedUploadIdCard(),
				"验证OrderId=[" + expect.getOrderId() + "]的NeedUploadIdCard");
		DataUtil.verifyEquals(expect.getHaveUploadedIdCard(),
				actual.getHaveUploadedIdCard(),
				"验证OrderId=[" + expect.getOrderId() + "]的HaveUploadedIdCard");
		DataUtil.verifyDateEquals(expect.getCreateOrderDate(),
				actual.getCreateOrderDate(),
				"验证OrderId=[" + expect.getOrderId() + "]的CreateOrderDate");
		DataUtil.verifyDateEquals(expect.getPaidTime(), actual.getPaidTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的PaidTime");
		DataUtil.verifyDateEquals(expect.getPostpayTime(),
				actual.getPostpayTime(), "验证OrderId=[" + expect.getOrderId()
						+ "]的PostpayTime");
		DataUtil.verifyDateEquals(expect.getDeliveryTime(),
				actual.getDeliveryTime(), "验证OrderId=[" + expect.getOrderId()
						+ "]的DeliveryTime");
		DataUtil.verifyDateEquals(expect.getOrderCancelledTime(),
				actual.getOrderCancelledTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的OrderCancelledTime");
		DataUtil.verifyDateEquals(expect.getOrderConfirmedTime(),
				actual.getOrderConfirmedTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的OrderConfirmedTime");
		DataUtil.verifyDateEquals(expect.getApplyPostPayTime(),
				actual.getApplyPostPayTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的ApplyPostPayTime");
		DataUtil.verifyEquals(expect.getOnlyNeedPayOnce(),
				actual.getOnlyNeedPayOnce(),
				"验证OrderId=[" + expect.getOrderId() + "]的OnlyNeedPayOnce");
		DataUtil.verifyEquals(expect.getCouponCode(), actual.getCouponCode(),
				"验证OrderId=[" + expect.getOrderId() + "]的CouponCode");
		DataUtil.verifyEquals(expect.getSellerCouponCode(),
				actual.getSellerCouponCode(),
				"验证OrderId=[" + expect.getOrderId() + "]的SellerCouponCode");
		DataUtil.verifyDecimalEquals(expect.getTotalProductPrice(),
				actual.getTotalProductPrice(),
				"验证OrderId=[" + expect.getOrderId() + "]的TotalProductPrice");
		DataUtil.verifyDecimalEquals(expect.getFreight(), actual.getFreight(),
				"验证OrderId=[" + expect.getOrderId() + "]的Freight");
		DataUtil.verifyDecimalEquals(expect.getExpectedTotalPayAmount(),
				actual.getExpectedTotalPayAmount(),
				"验证OrderId=[" + expect.getOrderId()
						+ "]的ExpectedTotalPayAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getCouponAmount()), actual
				.getCouponAmount(), "验证OrderId=[" + expect.getOrderId()
				+ "]的CouponAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getSellerCouponAmount()), actual
				.getSellerCouponAmount(), "验证OrderId=[" + expect.getOrderId()
				+ "]的SellerCouponAmount");
		DataUtil.verifyDecimalEquals(expect.getSellerPromotionAmount(),
				actual.getSellerPromotionAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的SellerPromotionAmount");
		DataUtil.verifyDecimalEquals(expect.getGiftAmount(),
				actual.getGiftAmount(), "验证OrderId=[" + expect.getOrderId()
						+ "]的GiftAmount");
		DataUtil.verifyDecimalEquals(expect.getDiscount(),
				actual.getDiscount(), "验证OrderId=[" + expect.getOrderId()
						+ "]的Discount");
		DataUtil.verifyDecimalEquals(expect.getExpectedPayAmount(),
				actual.getExpectedPayAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的ExpectedPayAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getExpectedPostpayAmount()), actual
				.getExpectedPostpayAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的ExpectedPostpayAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getOriginalPostpayAmount()), actual
				.getOriginalPostpayAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的OriginalPostpayAmount");
		DataUtil.verifyEquals(expect.getIsNewSellerOrder(),
				actual.getIsNewSellerOrder(),
				"验证OrderId=[" + expect.getOrderId() + "]的IsNewSellerOrder");
		DataUtil.verifyEquals(expect.getIsNewCustomerOrder(),
				actual.getIsNewCustomerOrder(),
				"验证OrderId=[" + expect.getOrderId() + "]的IsNewCustomerOrder");
		List<com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo> expProducts = expect
				.getProducts();
		List<com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo> actProducts = actual
				.getProducts();
		if (DataUtil.isNullOrEmpty(expProducts)) {
			DataUtil.verifyEquals(null, actProducts,
					"验证OrderId=[" + expect.getOrderId() + "]的Products为空");
		} else {
			for (com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo expProduct : expProducts) {
				String expProductId = expProduct.getProductId();
				boolean exists = actProducts.stream().anyMatch(
						x -> x.getProductId().equals(expProductId));
				DataUtil.verifyEquals(true, exists,
						"验证期望的OrderId=[" + expect.getOrderId()
								+ "]的ProductId=[" + expProductId + "]的产品记录是否存在");
				if (exists) {
					com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo actProduct = actProducts
							.stream()
							.filter(x -> x.getProductId().equals(expProductId))
							.collect(Collectors.toList()).get(0);
					verifyProduct(expProduct, actProduct, expect.getOrderId(),
							expProduct.getProductId());
				}
			}
		}
	}

	private void verifyProduct(
			com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo expect,
			com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo actual,
			int oid, String pid) {
		DataUtil.verifyDecimalEquals(expect.getProductPrice(),
				actual.getProductPrice(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductPrice");
		DataUtil.verifyDecimalEquals(expect.getProductOriginalPrice(),
				actual.getProductOriginalPrice(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductOriginalPrice");
		DataUtil.verifyEquals(expect.getProductPictureUrl(),
				actual.getProductPictureUrl(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductPictureUrl");
		DataUtil.verifyEquals(expect.getPropertyInfo(),
				actual.getPropertyInfo(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的PropertyInfo");
		DataUtil.verifyEquals(expect.getCatalogId(), actual.getCatalogId(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的CatalogId");
		DataUtil.verifyEquals(expect.getProductNum(), actual.getProductNum(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的ProductNum");
		DataUtil.verifyEquals(expect.getProductTitle(),
				actual.getProductTitle(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductTitle");
		DataUtil.verifyEquals(expect.getPriceType(), actual.getPriceType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的PriceType");
		DataUtil.verifyEquals(expect.getLogisticsType(),
				actual.getLogisticsType(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的LogisticsType");
		DataUtil.verifyEquals(expect.getProductRefundChannel(),
				actual.getProductRefundChannel(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductRefundChannel");
		DataUtil.verifyEquals(expect.isProductRefund(),
				actual.isProductRefund(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductRefund");
		DataUtil.verifyEquals(expect.getSalesRefundCode(),
				actual.getSalesRefundCode(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SalesRefundCode");
		DataUtil.verifyEquals(expect.getSalesRefundStatus(),
				actual.getSalesRefundStatus(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SalesRefundStatus");
		DataUtil.verifyDecimalEquals(expect.getSalesRefundAmount(),
				actual.getSalesRefundAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SalesRefundAmount");
		DataUtil.verifyDecimalEquals(expect.getCouponAmount(),
				actual.getCouponAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的CouponAmount");
		DataUtil.verifyDecimalEquals(expect.getSellerCouponAmount(),
				actual.getSellerCouponAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SellerCouponAmount");
		DataUtil.verifyDecimalEquals(expect.getFreightPartialAmount(),
				actual.getFreightPartialAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的FreightPartialAmount");
		DataUtil.verifyDecimalEquals(expect.getDiscountPartialAmount(),
				actual.getDiscountPartialAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的DiscountPartialAmount");
		DataUtil.verifyEquals(expect.getTariffType(), actual.getTariffType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的TariffType");
		DataUtil.verifyEquals(expect.getFreightFree(), actual.getFreightFree(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的FreightFree");
		DataUtil.verifyEquals(expect.getSupportRtnWithoutReason(),
				actual.getSupportRtnWithoutReason(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SupportRtnWithoutReason");
		// DataUtil.verifyEquals(expect.getCatalogStatus(),
		// actual.getCatalogStatus(), "验证期望的OrderId=[" + oid
		// + "]的ProductId=[" + pid + "]的CatalogStatus"); //原接口的bug,所以该属性不做比对
		DataUtil.verifyEquals(expect.getCatalogType(), actual.getCatalogType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的CatalogType");
		ProductPromotion expPromotion = expect.getPromotion();
		ProductPromotion actPromotion = actual.getPromotion();
		if (expPromotion == null) {
			DataUtil.verifyEquals(null, actPromotion, "验证Promotion为null");
		} else {
			verifyPromotion(expPromotion, actPromotion, oid, pid);
		}
	}

	private void verifyPromotion(ProductPromotion expected,
			ProductPromotion actual, int oid, String pid) {
		DataUtil.verifyEquals(expected.getCondition(), actual.getCondition(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的Promotion的Condition");
		DataUtil.verifyEquals(expected.getContent(), actual.getContent(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的Promotion的Content");
		DataUtil.verifyEquals(expected.getID(), actual.getID(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的Promotion的ID");
		DataUtil.verifyEquals(expected.getName(), actual.getName(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的Promotion的Name");
		DataUtil.verifyEquals(expected.getType(), actual.getType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的Promotion的Type");
		DataUtil.verifyDecimalEquals(expected.getPartialReducedAmount(),
				actual.getPartialReducedAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid
						+ "]的Promotion的PartialReducedAmount");
		DataUtil.verifyDecimalEquals(expected.getReducedAmount(),
				actual.getReducedAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的Promotion的ReducedAmount");
	}

	private void ConstructExpectedResponse(GetAppSellerOrderResponse response) {
		Process(response);
	}

	private void Process(GetAppSellerOrderResponse response) {
		Sp_GetAppSellerOrdersByOrderIds sp = new Sp_GetAppSellerOrdersByOrderIds();
		List<Integer> orderIds = new ArrayList<Integer>();
		if (getAppSellerOrderBean.getOrderId() != null) {
			orderIds.add(getAppSellerOrderBean.getOrderId());
		}
		sp.setOrderIds(orderIds);
		sp.setSellerId(getAppSellerOrderBean.getSellerId());
		sp.setDetail(true);
		sp.execute();

		List<SellerOrderInfoV3> orders = com.ymatou.query.seller.trading.api.parameter.SellerApp.Common
				.GetAppSellerOrdersFromDB(sp, true);
		response.setOrder((SellerOrderInfoDetail) orders.get(0));
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_001() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=17, bPaidInFull=1");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfoExt order = o.create17_PostPayOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_002() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=17, bPaidInFull=0");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create101_WaitPostPayOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_003() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=1");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create1_M2cOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_004() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=2");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create2_PayOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_005() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=3");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create3_ShippedOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_006() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=4");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create4_ApplyRefundOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_007() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=16");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create16_ApplyForPostPayOrder(userId,
					sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_008() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=12");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create12_UserCancelOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_009() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=13");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create13_SellerCancelOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_010() {
		Logger.start(true, "获取卖家订单详情成功,iTradingStatus=18");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create18_SystemCancelOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_011() {
		Logger.start(true, "获取卖家订单详情成功,不传SellerId");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create18_SystemCancelOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_012() {
		Logger.start(true, "获取卖家订单详情成功,SellerId和OrderId不匹配");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			C2COrderInfo order = o.create18_SystemCancelOrder(userId, sellerId);
			Thread.sleep(1500l);
			Logger.comment("完成准备订单数据");
			getAppSellerOrderBean.setSellerId(40444);
			getAppSellerOrderBean.setOrderId(order.getiOrderId());
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderFundInfo_013() {
		Logger.start(true, "获取卖家订单详情成功,OrderId不不存在");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			getAppSellerOrderBean.setSellerId(sellerId);
			getAppSellerOrderBean.setOrderId(404);
			getAppSellerOrderCall.setData(getAppSellerOrderBean);
			getAppSellerOrderCall.callService();
			Logger.verifyEquals("200", getAppSellerOrderCall.getCode(),
					"验证code");
			DataUtil.verifyEquals(null, getAppSellerOrderCall
					.getAppSellerOrderResponse().getOrder(), "验证Order为null");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}